class paramConfiger:
    '''
    config params
    '''
    # if search QR code: 1 or 0
    config_ifSearchQR = 1                     

    # threshold of body temperature
    config_bodyTemperatureThreshold = 37.3 

    # in frame_vr, rate = roi w / frame_vr w
    # in frame_vr, rate = roi h / frame_vr h
    config_vrFrameRoiRate_x = 0.5
    config_vrFrameRoiRate_y = 0.5

    # calulate body temperature method: 
    # 0=OCR(max_temperature, min_temperature), 
    # 1=calibration(pixlum~temperature)
    config_getTemperatureMethod = 0              
    
    # face detection confidence threshold
    config_faceDetectThreshold =  0.85         

    # in face recognition, compare 2 feature vectors. distance < this: very similar,quite sure are same person
    config_faceRecogThreshold_confirm =  13       

    # in face recognition, compare 2 feature vectors. distance < this: same person; distance > this: not same person
    config_faceRecogThreshold_notsure = 20    

    # in face recognition, compare 2 feature vectors. distance > this: not same person
    config_faceRecogThreshold_reject = 30    


    def __init__(self):
        self.config_ifSearchQR = 1                     
        self.config_bodyTemperatureThreshold = 37.3    
        self.config_vrFrameRoiRate_x = 0.5
        self.config_vrFrameRoiRate_y = 0.5
        self.config_getTemperatureMethod = 0
        self.config_faceDetectThreshold = 0.85         
        self.config_faceRecogThreshold_confirm = 13       
        self.config_faceRecogThreshold_notsure = 20    
        self.config_faceRecogThreshold_reject = 30       


    def loadConfigParams(self):
        print("loading config params from configParam.dat ......")
        with open("./configParam.dat") as lines:
            linelist = lines.readlines()
            for linestr in linelist:
                curline = linestr.split("#")[0]
                if "config_ifSearchQR" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_ifSearchQR = float(tmp)

                if "config_bodyTemperatureThreshold" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_bodyTemperatureThreshold = float(tmp)

                if "config_vrFrameRoiRate_x" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_vrFrameRoiRate_x = float(tmp)

                if "config_vrFrameRoiRate_y" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_vrFrameRoiRate_y = float(tmp)

                if "config_getTemperatureMethod" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_getTemperatureMethod = float(tmp)

                if "config_faceDetectThreshold" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_faceDetectThreshold = float(tmp)

                if "config_faceRecogThreshold_confirm" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_faceRecogThreshold_confirm = float(tmp)

                if "config_faceRecogThreshold_notsure" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_faceRecogThreshold_notsure = float(tmp)

                if "config_faceRecogThreshold_reject" in curline:
                    tmp = curline.split(":")[1].strip()
                    self.config_faceRecogThreshold_reject = float(tmp)

        print("config_ifSearchQR: ", self.config_ifSearchQR)
        print("config_bodyTemperatureThreshold: ", self.config_bodyTemperatureThreshold)
        print("config_vrFrameRoiRate_x: ", self.config_vrFrameRoiRate_x)
        print("config_vrFrameRoiRate_y: ", self.config_vrFrameRoiRate_y)
        print("config_getTemperatureMethod: ", self.config_getTemperatureMethod)
        print("config_faceDetectThreshold: ", self.config_faceDetectThreshold)
        print("config_faceRecogThreshold_confirm: ", self.config_faceRecogThreshold_confirm)
        print("config_faceRecogThreshold_notsure: ", self.config_faceRecogThreshold_notsure)
        print("config_faceRecogThreshold_reject: ", self.config_faceRecogThreshold_reject)


if __name__ == "__main__":
    p = paramConfiger()
    print("p.config_ifSearchQR: ", p.config_ifSearchQR)
    p.loadConfigParams()

